package com.idea.cery.springboot1.dao;

import com.idea.cery.springboot1.bean.UserOrderInfo;
import com.idea.cery.springboot1.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author cery
 * @deprecated 单数据库 mybatis mapper(参考配置 本系统结构没有使用)
 */
@Mapper
@Repository
public interface MybatisDao {
    /**
     * 添加
     *
     * @param user
     * @return
     */
    @Insert("insert into t_user(id,name,age,status) values(#{id},#{name},#{age},#{status})")
    int add(User user);

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Delete("delete from t_user where id=#{id}")
    int del(String id);

    /**
     * 更新
     *
     * @param user
     * @return
     */
    @Update("update t_user set age=#{age} where id=#{id}")
    int upd(User user);

    /**
     * 查询
     *
     * @return
     */
    @Select("select * from t_user")
    List<User> list();

    /**
     * 连接查询
     *
     * @param id
     * @return
     */
    @Select("select tu.id, tu.name, tuo.order, tuo.address, tuo.date from t_user tu, tu_order tuo where tu.id=#{id} and tu.id=tuo.userid")
    List<UserOrderInfo> getOrderByName(@Param("id") String id);

}
